package smedi.ismedi.mobile.bff.controller.organization;

import com.smedi.ismedi.organization.api.dto.response.ProjectOrganizationResponse;
import com.smedi.ismedi.organization.api.feign.RemoteProjectOrganizationFeignApi;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import smedi.ismedi.mobile.bff.controller.BaseController;

import java.util.List;

/**
 * 项目组织BFF
 *
 * @author xulinjun
 */
@Slf4j
@RestController
@Api(tags = {"项目组织架构维护接口"})
@RequestMapping("/mobilebff/v1/projectOrganization")
@AllArgsConstructor
public class ProjectOrganizationController extends BaseController {
    private final RemoteProjectOrganizationFeignApi remoteProjectOrganizationFeignApi;

    /**
     * 根据项目id获取项目下的企业组织列表
     *
     * @param projectId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据项目id获取项目下的企业组织列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long"),
    })
    @GetMapping(value = "/queryProjectOrganizationListByProjectId")
    public ResponseData<List<ProjectOrganizationResponse>> getQueryProjectOrganizationListByProjectId(@RequestParam(value = "projectId") Long projectId) {
        return remoteProjectOrganizationFeignApi.getQueryProjectOrganizationListByProjectId(projectId);
    }

    /**
     * 根据项目id和特殊类型获取到符合的项目组织
     *
     * @param projectId
     * @param specialTypes
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据项目id和特殊类型获取到符合的项目组织")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "specialTypes", value = "特殊类型", dataType = "List", dataTypeClass = List.class)
    })
    @GetMapping(value = "/getProjectOrganizationByProjectIdAndSpecialType")
    public ResponseData<List<ProjectOrganizationResponse>> getProjectOrganizationByProjectIdAndSpecialType(@RequestParam("projectId") Long projectId,
                                                                                                           @RequestParam("specialTypes") List<String> specialTypes) {
        return remoteProjectOrganizationFeignApi.getProjectOrganizationByProjectIdAndSpecialType(projectId, specialTypes);
    }
    /**
     * 根据项目id获取项目下的分包单位
     *
     * @param projectId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据项目id获取项目下的分包单位")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/queryProjectOrganizationsByProjectId")
    ResponseData<List<String>> getQueryProjectOrganizationsByProjectId(@RequestParam(value = "projectId") Long projectId){
        return remoteProjectOrganizationFeignApi.getQueryProjectOrganizationsByProjectId(projectId);
    }
}
